package com.example.framework2002a.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.BindingAdapter;
import androidx.databinding.DataBindingUtil;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.framework2002a.R;
import com.example.framework2002a.databinding.ItemFoodBinding;
import com.example.lib_core.bean.FoodBean;

import java.util.List;

public class FoodAdapter extends BaseQuickAdapter<FoodBean, BaseViewHolder> {

    public FoodAdapter(@Nullable List<FoodBean> data) {
        super(R.layout.item_food, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, FoodBean dataBean) {
        ItemFoodBinding binding = DataBindingUtil.getBinding(baseViewHolder.itemView);
        if (binding != null){
            binding.setFood(dataBean);
            binding.executePendingBindings();
        }
    }

    @Override
    protected void onItemViewHolderCreated(@NonNull BaseViewHolder viewHolder, int viewType) {
        super.onItemViewHolderCreated(viewHolder, viewType);
        DataBindingUtil.bind(viewHolder.itemView);
    }
}
